package com.husong.controller;

import com.husong.controller.base.BaseController;
import com.husong.entity.Advert;
import com.husong.enums.AuthodType;
import com.husong.pojo.ReturnJsonBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author MaxMin.
 */
@Controller
@RequestMapping("/advert")
public class AdvertController extends BaseController {

    @RequestMapping("/list")
    @ResponseBody
    public ReturnJsonBean list(String cityname) {
        ReturnJsonBean rb = new ReturnJsonBean();
        try {
            List<Advert> list = advertService.findByCityName(cityname);
            rb.setData(list);
            returnSuccess(rb);
        } catch (Exception e) {
            e.printStackTrace();
            saveException(AuthodType.jincongmin.getName(), "AdvertController", "index()", e);
        }
        return rb;
    }
}
